package com.application.lucky.manager;

import com.application.lucky.Lucky;
import com.application.mylibrary.utils.SharedPreferencesUtil;

import java.util.ArrayList;
import java.util.List;

public class RedManager {
    public static void saveMoney(String money) {
        if (isCheck()) {
            SharedPreferencesUtil.saveString(Lucky.getApplication(), "money", money);
        }
        if(isCheck()){
            RedManager.saveYuShe(money);
        }

    }

    public static void saveYuShe(String money) {
        if (isCheck()) {
            SharedPreferencesUtil.saveString(Lucky.getApplication(), "YuShe", money);
        }

    }

    public static String getYuShe() {
       return SharedPreferencesUtil.getString(Lucky.getApplication(), "YuShe","");

    }

    public static void saveLieDian(String leidian) {
        SharedPreferencesUtil.saveString(Lucky.getApplication(), "leidian", leidian);
    }

    public static String getMOney() {
        return SharedPreferencesUtil.getString(Lucky.getApplication(), "money", "");
    }

    public static List<String> getLeidian() {
        String leidian = SharedPreferencesUtil.getString(Lucky.getApplication(), "leidian", "");
        String[] split = leidian.split(",");
        List<String> integers = new ArrayList<>();
        try {
            for (String s : split) {
                if ("0".equals(s)) {
                    integers.add("10");
                } else {
                    integers.add((Integer.valueOf(s) - 1) + "");
                }

            }
        } catch (Exception e) {
            e.printStackTrace();
        }

        return integers;
    }

    public static boolean isCheck() {
        return SharedPreferencesUtil.getBoolean(Lucky.getApplication(), "ischeck", true);
    }

    public static void saveCHeck(boolean is) {
        SharedPreferencesUtil.saveBoolean(Lucky.getApplication(), "ischeck", is);
    }
}
